<template>
    <div>
        <table>
            <tr>
                <td>id</td>
                <td>商品名称</td>
                <td>商品分类</td>
                <td>操作</td>
            </tr>
            <tr v-for="i in goods">
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td><button @click="show(i.cate)">{{i.cate}}</button></td>
                <td><button @click='del(i.id)'>删除</button></td>
            </tr> 
        </table>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                goods:[],
                uid:0
            }
        },
        methods:{
            get_good(cate){
                this.$axios.get('good?uid='+this.uid+'&cate='+cate).then(res=>{
                    this.goods =res.data.list
                })
            },
            del(id){
                this.$axios.delete('good?id='+id).then(res=>{
                    this.get_good()
                })
            },
            show(cate){
                this.uid=1
                this.get_good(cate)
            }
        },
        mounted(){
            this.get_good()
        }
    }
</script>

<style scoped>

</style>